<template>
	<view class="logistics">	
		<view class="title">
			<image :src="pic" mode="widthFix"></image>
			<view class="logisticsCompany">
				<view class="companyName" v-if="expTextName">
					物流公司：<text>{{expTextName}}</text>
				</view>
				<view class="logisticsNum">
					物流单号：<text>{{sn}}</text> <text class="copyBtn" @tap="copyNum">复制</text>
				</view>
			</view>
		</view>
		<view class="logisticsInfo">
			<view class="desction" v-for="(item,indx) in  logisticsInfo" :key="index">
				<text class="point"></text>
				<view class="info">
					{{item.context}}
				</view>
				<view class="time">
					{{item.time}}
				</view>
			</view>
			
		</view>
		<view class="titles">
			<image src="../../static/images/like_icon.png" mode="widthFix"></image>
			你可能还会喜欢
		</view>
		<view class="uni-list selectLists">
			<view class="uni-list-cell selectList" v-for="(item,index) in selectList" :key="index" @tap="goDetails(item)">
				<view class="imgbox">
					<image :src="item.pic.split(',')[0]" mode=""></image>
				</view>
				<view class="desction">
					{{item.name}}
				</view>
				<view class="priceBox">
					<view class="price">
						￥{{item.price}}
					</view>
					<view class="salesNum">
						总销量{{item.sale}}
					</view>
				</view>
			</view>
		</view>
		<view class="loadStatusText">
			{{loadStatusText}}
		</view>
	</view>
</template>

<script>
	export default{
		data() {
			return {
				selectList:[],
				pageNum:1,
				loadStatusText: '加载中...',
				sn:"",
				orderId:"",
				expTextName:"",
				pic:"",
				logisticsInfo:[]
			}
		},
		onLoad(e) {
			// this.sn = e.sn
			this.orderId = e.orderId
			this.getLikeList();
			this.getlogistic()
		},
		onReachBottom() {
			this.getLikeList()
		},
		methods:{
			copyNum(){
				uni.setClipboardData({
				    data: this.sn,
				    success: function () {
				        console.log('success');
						uni.showToast({
							title:"复制成功",
							icon:"none"
						})
				    }
				});
			},
			getLikeList(){
					let data = {
						  "pageNum": this.pageNum,
						  "pageSize": 10,
						  "recommandStatus": 0,
					}
					var _this = this
					this.$http.post(this.$http.baseUrl + '/api/v1.0/app/product/ProductTopSell',data,res=>{
						this.pageNum++
						if(res.data.data.length == 0){
							_this.loadStatusText = "已加载全部"
							return false;
						}else{
							_this.loadStatusText = "加载成功"
							if(_this.selectList.length == 0){
								_this.selectList = res.data.data;
							}else{
								_this.selectList = _this.selectList.concat(res.data.data);
								_this.loadStatusText = "加载成功"
							}
						}
					})
			},
			getlogistic(){
				let data = {
					orderId:this.orderId
				}
				this.$http.post('/api/v1.0/order/product/logistics',data,res=>{
					console.log(res)
					this.expTextName = res.data.data.expTextName
					this.pic = res.data.data.logo;
					this.sn = res.data.data.mailNo;
					this.logisticsInfo = res.data.data.logisticsInfo;
					
				})
			},
			goDetails(item){
				uni.navigateTo({
					url: '/pages/details/details?id=' + item.id
				})
			}
		}
	}
</script>

<style lang="scss">
	.logistics{
		min-height: 100vh;
		background-color: #f2f2f2;
		padding: 40upx 28upx;
		.title{
			background-color: #fff;
			border-radius: 20upx;
			padding: 20upx;
			box-sizing: border-box;
			display: flex;
			justify-content: flex-start;
			align-items: center;
			image{
				width: 153upx;
				height: 153upx;
				margin-right: 20upx;
			}
			.logisticsCompany{
				color: #999999;
				font-size: 26upx;
				.companyName{
					text{
						color: #333;
					}
				}
				.logisticsNum{
					text{
						color: #333333;
					}
					.copyBtn{
						display: inline-block;
						border: 1upx solid #ccc;
						color: #676767;
						width: 73upx;
						height: 30upx;
						text-align: center;
						line-height: 26upx;
						margin-left: 20upx;
						border-radius: 5upx;
					}
				}
			}
		}
		.logisticsInfo{
			margin-top: 20upx;
			padding: 50upx 20upx 50upx 30upx;
			background-color: #fff;
			border-radius: 20upx;
			.desction{
				position: relative;
				border-left: 1upx solid #E6E6E6;
				padding-left: 25upx;
				padding-bottom: 50upx;
				&:last-child{
					border-left: 1upx solid transparent;
				}
				.point{
					display: inline-block;
					position: absolute;
					top: 0upx;
					left: -5upx;
					width: 10upx;
					height: 10upx;
					border-radius: 50%;
					background-color: #ccc;
				}
				.info{
					position: relative;
					top: -10upx;
					font-size: 24upx;
				}
				.time{
					font-size: 22upx;
					color: #999;
				}
			}
		}
		.titles{
			font-size: 28upx;
			color: #4d4d4d;
			text-align: center;
			margin-top: 60upx;
			margin-bottom: 30upx;
			image{
				width: 28upx;
				height: 28upx;
				margin-right: 10upx;
			}
		}
		.selectLists{
				margin-top: 50upx;
				display: flex;
				justify-content: space-between;
				flex-wrap: wrap;
				.selectList{
					border-radius: 20upx;
					background-color: #fff;
					overflow: hidden;
					width: 334.3upx;
					height: 530upx;
					margin-right: 25.7upx;
					margin-bottom: 26upx;
					&:nth-child(2n){
						margin-right: 0;
					}
					image{
						width: 334.3upx;
						height: 333upx;					
					}
					.desction{
						width: 297upx;
						margin: 24upx auto;
						color: #333;
						font-weight: 500;
						font-size: 28upx;
						display: -webkit-box;
						overflow: hidden; 
						white-space: normal!important;
						text-overflow: ellipsis;
						word-wrap: break-word; 
						-webkit-line-clamp: 2;
						-webkit-box-orient: vertical;
						
					}
					.priceBox{
						display: flex;
						justify-content: space-between;
						width: 297upx;
						margin: 0 auto;
						.price{
						color: #F63810;
						font-size: 24upx;
							text{
								font-size: 32upx;
								font-weight: bold;
							}
						}
						.salesNum{
							color: #4d4d4d;
							font-size: 24upx;
						}
					}
					
				}
			}
			.loadStatusText{
				font-size: 24upx;
				text-align: center;
				color: #999999;
				height: 100upx;
				line-height: 100upx;
			}
		
	}
</style>
